public class Problem23 {
	public static void main(String[] args) {
		int[] numbers = new int[28124];

		for (int i = 0; i <= 28123; ++i)
			numbers[i] = abundant_or_deficient_or_perfect(i);

		int sum = 0;
		for (int i = 1; i <= 28123; ++i) {
			if (cannot_be_written_as_sum_of_two_abundant_numbers(numbers, i))
				sum += i;	
		}

		System.out.println("" + sum);
	}

	private static boolean cannot_be_written_as_sum_of_two_abundant_numbers(int[] numbers, int x) {
		if (x == 0)
			return false;
		if( x > 28123)
			return true;

		assert (x >= 1 && x <= 28123);

		for (int i = 1; i < numbers.length && i <= x; ++i) {
			if (numbers[i] > 0 && numbers[x-i] > 0)
				return false;
		}

		return true;
	}
	
	private static int abundant_or_deficient_or_perfect (int x) {
		int sum = 0;
		for (int i = 1; i <= Math.sqrt(x); ++i) {
			if (x % i == 0) {
				sum += i;
				sum += x/i;	
			}
		}

		if ((int)Math.sqrt(x) * (int)Math.sqrt(x) == x)	
			sum -= Math.sqrt(x);

		sum -= x;

		if (sum == x)
			return 0;
		else if (sum < x)
			return -1;
		else
			return 1;
	}
}
